<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var a = [5,1,8,10,4];
        // should output: [10,8,5,4,1]
        b=a.sort(function (a,b){return b-a})
        console.log(b)
    </script>
</head>
<body>

</body>
</html>